USE [g21-A-db1]
GO
/****** Object:  Table [dbo].[technician]    Script Date: 04/23/2009 14:27:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[technician](
	[id] [varchar](30) NOT NULL,
	[password] [varchar](30) NULL,
	[name] [varchar](50) NOT NULL,
	[district] [varchar](30) NOT NULL,
	[category] [smallint] NOT NULL,
	[supervisor] [varchar](30) NULL,
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [MSmerge_df_rowguid_173E69DC2BFA460CA7904812EDE9431C]  DEFAULT (newsequentialid()),
PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[residence]    Script Date: 04/23/2009 14:27:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[residence](
	[resi_id] [smallint] NOT NULL,
	[address] [varchar](70) NOT NULL,
	[district] [varchar](30) NOT NULL,
	[client] [varchar](50) NOT NULL,
	[topology] [varchar](5) NULL,
	[cooling] [smallint] NULL,
	[heating] [smallint] NULL,
	[isolation] [smallint] NULL,
	[coverage] [varchar](15) NULL,
	[glasses] [varchar](15) NULL,
	[category] [smallint] NOT NULL DEFAULT ((-1)),
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [MSmerge_df_rowguid_0E7322064B9F421AB5585A0577461517]  DEFAULT (newsequentialid()),
PRIMARY KEY CLUSTERED 
(
	[resi_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[resi_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[visiting_residence]    Script Date: 04/23/2009 14:27:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[visiting_residence](
	[resi_id] [smallint] NOT NULL,
	[id] [varchar](30) NOT NULL,
	[visit_date] [datetime] NOT NULL,
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [MSmerge_df_rowguid_FD835FF772134B79AE54B00AF3A20AA3]  DEFAULT (newsequentialid()),
PRIMARY KEY CLUSTERED 
(
	[resi_id] ASC,
	[id] ASC,
	[visit_date] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  ForeignKey [FK__technicia__super__7B1C2680]    Script Date: 04/23/2009 14:27:26 ******/
ALTER TABLE [dbo].[technician]  WITH CHECK ADD FOREIGN KEY([supervisor])
REFERENCES [dbo].[technician] ([id])
GO
/****** Object:  ForeignKey [FK__visiting___resi___01C9240F]    Script Date: 04/23/2009 14:27:32 ******/
ALTER TABLE [dbo].[visiting_residence]  WITH CHECK ADD FOREIGN KEY([resi_id])
REFERENCES [dbo].[residence] ([resi_id])
GO
/****** Object:  ForeignKey [FK__visiting_res__id__02BD4848]    Script Date: 04/23/2009 14:27:32 ******/
ALTER TABLE [dbo].[visiting_residence]  WITH CHECK ADD FOREIGN KEY([id])
REFERENCES [dbo].[technician] ([id])
GO
